
function valveDonwload(){

    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = "";
    }
    if (endMileage == null || endMileage == "") {
        endMileage = "";
    }

    $("input[name='pipeLineId']").val(lineId);
    $("input[name='pipeSegmentId']").val(segmentId);
    $("input[name='startMileage']").val(startMileage);
    $("input[name='endMileage']").val(endMileage);

    $("#valveForm").attr("action", pagePath + "/basedata/PipeValveController/getExcel.html");
    $("#valveForm").submit();
}


/**
 *
 */
function getValveClick(){

    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = "";
    }
    if (endMileage == null || endMileage == "") {
        endMileage = "";
    }

    //给隐藏表单域赋值
    $("#lineHiddenId").val(lineId);
    $("#segmentHiddenId").val(segmentId);
    $("#startMileHiddenId").val(startMileage);
    $("#endMileHiddenId").val(endMileage);

    var data = {"pipeLineId":lineId,"pipeSegmentId":segmentId, "startMileage":startMileage, "endMileage":endMileage};

    var b = window.sessionStorage;
    b.removeItem("mapData");
    b.setItem("mapData", JSON.stringify(data));

    var map={"fillDiv":"#searchBody", "url":""+pagePath+"/basedata/PipeValveController/getDetails.json"};

    searchPage(map,data);
}


Date.prototype.Format = function(format){ 
	var o = { 
	"M+" : this.getMonth()+1, //month 
	"d+" : this.getDate(), //day 
	"h+" : this.getHours(), //hour 
	"m+" : this.getMinutes(), //minute 
	"s+" : this.getSeconds(), //second 
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter 
	"S" : this.getMilliseconds() //millisecond 
	} 

	if(/(y+)/.test(format)) { 
	format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	} 

	for(var k in o) { 
	if(new RegExp("("+ k +")").test(format)) { 
	format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); 
	} 
	} 
	return format; 
	} 




function createProHtml(p,i){
	 var html='';
     var hangClass='ul-header bg-white';
     if(i%2!=0){
       hangClass='ul-header bg-second';
     }
     var code =p.CODE;
     if(code==""||code ==null){
     	code="-";
     }
   //管线名称
		var lineName="";
		if(""==p||null==p||""==p.LINENAME||null==p.LINENAME){
			lineName="-";
		}else{
			lineName=p.LINENAME;
		}
		
		//管段名称名称
		var segmentName="";
		if(""==p||null==p||""==p.SEGMENTNAME||null==p.SEGMENTNAME){
			segmentName="-";
		}else{
			segmentName=p.SEGMENTNAME;
		}
		
		//阀门编号
		var VALVA_NUMBER="";
		if(""==p||null==p||""==p.VALVA_NUMBER||null==p.VALVA_NUMBER){
			VALVA_NUMBER="-";
		}else{
			VALVA_NUMBER=p.VALVA_NUMBER;
		}
		
		//门阀状态
		var VALVE_STATUS="";
		if(""==p||null==p||""==p.VALVE_STATUS||null==p.VALVE_STATUS){
			VALVE_STATUS="-";
		}else{
			VALVE_STATUS=p.VALVE_STATUS;
		}
		
		//出厂编号
		var MANUFACTURED_NUM="";
		if(""==p||null==p||""==p.MANUFACTURED_NUM||null==p.MANUFACTURED_NUM){
			MANUFACTURED_NUM="-";
		}else{
			MANUFACTURED_NUM=p.MANUFACTURED_NUM;
		}
		
		//阀门类型
		var VALVE_TYPE="";
		if(""==p||null==p||""==p.VALVE_TYPE||null==p.VALVE_TYPE){
			VALVE_TYPE="-";
		}else{
			VALVE_TYPE=p.VALVE_TYPE;
		}
		
		//驱动类型
		var OPERATOR_TYPE="";
		if(""==p||null==p||""==p.OPERATOR_TYPE||null==p.OPERATOR_TYPE){
			OPERATOR_TYPE="-";
		}else{
			OPERATOR_TYPE=p.OPERATOR_TYPE;
		}
		
		//所属场站阀室
		var AFFILIATIONSITEOR_VALVE="";
		if(""==p||null==p||""==p.AFFILIATIONSITEOR_VALVE||null==p.AFFILIATIONSITEOR_VALVE){
			AFFILIATIONSITEOR_VALVE="-";
		}else{
			AFFILIATIONSITEOR_VALVE=p.AFFILIATIONSITEOR_VALVE;
		}
		
		//绝对距离
		var MILEAGE=""+p.MILEAGE;
		if(""==p||null==p||""==MILEAGE||null==MILEAGE||"undefined"==MILEAGE){
			MILEAGE="-";
		}
		
		//最近参考点
		var REFERENCE="";
		if(""==p||null==p||""==p.REFERENCE||null==p.REFERENCE){
			REFERENCE="-";
		}else{
			REFERENCE=p.REFERENCE;
		}
		
		
		//相对最近参考点距离
		var REFERENCE_DISTANCE="";
		if(""==p||null==p||""==p.REFERENCE_DISTANCE||null==p.REFERENCE_DISTANCE){
			REFERENCE_DISTANCE="-";
		}else{
			REFERENCE_DISTANCE=p.REFERENCE_DISTANCE;
		}
		
		//是否为自动阀
		var AUTOMATED="";
		if(""==p||null==p||""==p.AUTOMATED||null==p.AUTOMATED){
			AUTOMATED="-";
		}else{
			AUTOMATED=p.AUTOMATED;
		}
		
		//进口连接类型
		var INLET_CONNECTION_TYPE="";
		if(""==p||null==p||""==p.INLET_CONNECTION_TYPE||null==p.INLET_CONNECTION_TYPE){
			INLET_CONNECTION_TYPE="-";
		}else{
			INLET_CONNECTION_TYPE=p.INLET_CONNECTION_TYPE;
		}
		
		//进口直径
		var INLET_DIAMETER=""+p.INLET_DIAMETER;
		if(""==p||null==p||""==INLET_DIAMETER||null==INLET_DIAMETER||"undefined"==INLET_DIAMETER){
			INLET_DIAMETER="-";
		}
		
		//进口壁厚
		var INLET_WALL_THICKNESS=""+p.INLET_WALL_THICKNESS;
		if(""==p||null==p||""==INLET_WALL_THICKNESS||null==INLET_WALL_THICKNESS||"undefined"==INLET_WALL_THICKNESS){
			INLET_WALL_THICKNESS="-";
		}
		
		//出口类型
		var OUTLET_CONNECTION_TYPE="";
		if(""==p||null==p||""==p.OUTLET_CONNECTION_TYPE||null==p.OUTLET_CONNECTION_TYPE){
			OUTLET_CONNECTION_TYPE="-";
		}else{
			OUTLET_CONNECTION_TYPE=p.OUTLET_CONNECTION_TYPE;
		}
		
		//出口直径
		var OUTLET_DIAMETER=""+p.OUTLET_DIAMETER;
		if(""==p||null==p||""==OUTLET_DIAMETER||null==OUTLET_DIAMETER||"undefined"==OUTLET_DIAMETER){
			OUTLET_DIAMETER="-";
		}
		
		//出口壁厚
		var OUTLET_WALL_THICKNESS=""+p.OUTLET_WALL_THICKNESS;
		if(""==p||null==p||""==OUTLET_WALL_THICKNESS||null==OUTLET_WALL_THICKNESS||"undefined"==OUTLET_WALL_THICKNESS){
			OUTLET_WALL_THICKNESS="-";
		}
		
		
		//压力等级
		var PRESSURE_RATING=""+p.PRESSURE_RATING;
		if(""==p||null==p||""==PRESSURE_RATING||null==PRESSURE_RATING||"undefined"==PRESSURE_RATING){
			PRESSURE_RATING="-";
		}
		
		//门阀功能
		var VALVEFUNCTION="";
		if(""==p||null==p||""==p.VALVEFUNCTION||null==p.VALVEFUNCTION){
			VALVEFUNCTION="-";
		}else{
			VALVEFUNCTION=p.VALVEFUNCTION;
		}
		
		//是否可以远程控制
		var INDREMOTECON="";
		if(""==p||null==p||""==p.INDREMOTECON||null==p.INDREMOTECON){
			INDREMOTECON="-";
		}else{
			INDREMOTECON=p.INDREMOTECON;
		}
		
		//修复建议
		var REPAIR_SUGGESTIONG="";
		if(""==p||null==p||""==p.REPAIR_SUGGESTIONG||null==p.REPAIR_SUGGESTIONG){
			REPAIR_SUGGESTIONG="-";
		}else{
			REPAIR_SUGGESTIONG=p.REPAIR_SUGGESTIONG;
		}
		
		//修复状态
		var REPAIR_STATE="";
		if(""==p||null==p||""==p.REPAIR_STATE||null==p.REPAIR_STATE){
			REPAIR_STATE="-";
		}else{
			REPAIR_STATE=p.REPAIR_STATE;
		}
		
		//生产厂商
		var MANUFACTURER="";
		if(""==p||null==p||""==p.MANUFACTURER||null==p.MANUFACTURER){
			MANUFACTURER="-";
		}else{
			MANUFACTURER=p.MANUFACTURER;
		}
		
		//生产日期
		var MANUFACTURED_DATE="";
		if(""==p||null==p||""==p.MANUFACTURED_DATE||null==p.MANUFACTURED_DATE){
			MANUFACTURED_DATE="-";
		}else{
			MANUFACTURED_DATE=new Date(p.MANUFACTURED_DATE).Format("yyyy-MM-dd");
		}
		
		//投用日期
		var INSERVICE_DATE="";
		if(""==p||null==p||""==p.INSERVICE_DATE||null==p.INSERVICE_DATE){
			INSERVICE_DATE="-";
		}else{
			INSERVICE_DATE=new Date(p.INSERVICE_DATE).Format("yyyy-MM-dd");
		}
		
		//施工单位
		var CONSTRUCTION_COMPANY="";
		if(""==p||null==p||""==p.CONSTRUCTION_COMPANY||null==p.CONSTRUCTION_COMPANY){
			CONSTRUCTION_COMPANY="-";
		}else{
			CONSTRUCTION_COMPANY=p.CONSTRUCTION_COMPANY;
		}
		
		//监理单位
		var INSPECTING_COMPANY="";
		if(""==p||null==p||""==p.INSPECTING_COMPANY||null==p.INSPECTING_COMPANY){
			INSPECTING_COMPANY="-";
		}else{
			INSPECTING_COMPANY=p.INSPECTING_COMPANY;
		}
		
		//检测单位
		var TESTING_COMPANY="";
		if(""==p||null==p||""==p.TESTING_COMPANY||null==p.TESTING_COMPANY){
			TESTING_COMPANY="-";
		}else{
			TESTING_COMPANY=p.TESTING_COMPANY;
		}
		
		//记录人
		var RECORDER="";
		if(""==p||null==p||""==p.RECORDER||null==p.RECORDER){
			RECORDER="-";
		}else{
			RECORDER=p.RECORDER;
		}
		
		//记录时间
		var RECORDTIME="";
		if(""==p||null==p||""==p.RECORDTIME||null==p.RECORDTIME){
			RECORDTIME="-";
		}else{
			RECORDTIME=new Date(p.RECORDTIME).Format("yyyy-MM-dd");
			console.log(RECORDTIME);
		}
		
		//备注
		var CREATE_REMARK="";
		if(""==p||null==p||""==p.CREATE_REMARK||null==p.CREATE_REMARK){
			CREATE_REMARK="-";
		}else{
			CREATE_REMARK=p.CREATE_REMARK;
		}
		
		//GISID
		var GIS_ID="";
		if(""==p||null==p||""==p.GIS_ID||null==p.GIS_ID){
			GIS_ID="";
		}else{
			GIS_ID=p.GIS_ID;
		}
		
		
		//详情数据
		var hhtml='<div class=\"show-ul none\">'
			+' <ul class=\"show-list\">'
			+'<li> <span class=\"s1\">统一编号:</span><span class=\"s2\">'+code+'</span></li>'
			+'<li> <span class=\"s1\">管道名称:</span><span class=\"s2\">'+lineName+'</span></li>'
			+'<li> <span class=\"s1\">管段名称:</span> <span class=\"s2\">'+segmentName+'</span></li>'
			+'<li> <span class=\"s1\">阀门编号:</span> <span class=\"s2\">'+VALVA_NUMBER+'</span></li>'
			+'<li> <span class=\"s1\">阀门状态:</span> <span class=\"s2\">'+VALVE_STATUS+'</span></li>'
			+'<li> <span class=\"s1\">出厂编号:</span> <span class=\"s2\">'+MANUFACTURED_NUM+'</span></li>'
			+'<li> <span class=\"s1\">阀门类型:</span> <span class=\"s2\"></span>'+VALVE_TYPE+'</li>'
			+'<li> <span class=\"s1\">驱动类型:</span> <span class=\"s2\">'+OPERATOR_TYPE+'</span></li>'
			+'<li> <span class=\"s1\">所属场站阀室:</span> <span class=\"s2\">'+AFFILIATIONSITEOR_VALVE+'</span></li>'
			+'<li> <span class=\"s1\">绝对距离(m):</span> <span class=\"s2\">'+MILEAGE+'</span></li>'
			+'<li> <span class=\"s1\">最近参考点:</span> <span class=\"s2\">'+REFERENCE+'</span></li>'
			+'<li> <span class=\"s1\">相对距离参考点(m):</span> <span class=\"s2\">'+REFERENCE_DISTANCE+'</span></li>'
			+'<li> <span class=\"s1\">是否为自动阀:</span> <span class=\"s2\">'+AUTOMATED+'</span></li>'
			+'<li> <span class=\"s1\">进口连接类型:</span> <span class=\"s2\">'+INLET_CONNECTION_TYPE+'</span></li>'
			+'<li> <span class=\"s1\">进口直径(mm):</span> <span class=\"s2\">'+INLET_DIAMETER+'</span></li>'
			+'<li> <span class=\"s1\">进口壁厚(mm):</span> <span class=\"s2\">'+INLET_WALL_THICKNESS+'</span></li>'
			+'<li> <span class=\"s1\">出口连接类型:</span> <span class=\"s2\">'+OUTLET_CONNECTION_TYPE+'</span></li>'
			+'<li> <span class=\"s1\">出口直径(mm):</span> <span class=\"s2\">'+OUTLET_DIAMETER+'</span></li>'
			+'<li> <span class=\"s1\">出口壁厚(mm):</span> <span class=\"s2\">'+OUTLET_WALL_THICKNESS+'</span></li>'
			+'<li> <span class=\"s1\">压力等级(MPa):</span> <span class=\"s2\">'+PRESSURE_RATING+'</span></li>'
			+'<li> <span class=\"s1\">阀门功能:</span> <span class=\"s2\">'+VALVEFUNCTION+'</span></li>'
			+'<li> <span class=\"s1\">是否可远程控制:</span> <span class=\"s2\">'+INDREMOTECON+'</span></li>'
			+'<li> <span class=\"s1\">修复建议:</span> <span class=\"s2\">'+REPAIR_SUGGESTIONG+'</span></li>'
			+'<li> <span class=\"s1\">修复状态:</span> <span class=\"s2\">'+REPAIR_STATE+'</span></li>'
			+'<li> <span class=\"s1\">生产厂商:</span> <span class=\"s2\">'+MANUFACTURER+'</span></li>'
			+'<li> <span class=\"s1\">生产日期:</span> <span class=\"s2\">'+MANUFACTURED_DATE+'</span></li>'
			+'<li> <span class=\"s1\">投用日期:</span> <span class=\"s2\">'+INSERVICE_DATE+'</span></li>'
			+'<li> <span class=\"s1\">施工单位:</span> <span class=\"s2\">'+CONSTRUCTION_COMPANY+'</span></li>'
			+'<li> <span class=\"s1\">监理单位:</span> <span class=\"s2\">'+INSPECTING_COMPANY+'</span></li>'
			+'<li> <span class=\"s1\">检测单位:</span> <span class=\"s2\">'+TESTING_COMPANY+'</span></li>'
			+'<li> <span class=\"s1\">记录人:</span> <span class=\"s2\">'+RECORDER+'</span></li>'
			+'<li> <span class=\"s1\">记录时间:</span> <span class=\"s2\">'+RECORDTIME+'</span></li>'
			+'<li class=\"last-li\"><span class=\"s1\">备注:</span><span class=\"s2\"><textarea placeholder=\"备注描述\">'+CREATE_REMARK+'</textarea></span></li>'
			+'</ul></div></div><input type="hidden" name="gisHiddenName" value=' + GIS_ID + '>';
			
			
		html += '<div class=\"info-tr\"><ul class=\"ul-header '
			+ hangClass
			+ '\"><li class=\"w20\">'
			+ lineName
			+ '</li><li class=\"w20\">'
			+ segmentName
			+ '</li><li class=\"w20\">'
			+ VALVA_NUMBER
			+ '</li><li class=\"w10\">'
			+ VALVE_TYPE
			+ '</li><li class="w20">'
			+ VALVE_STATUS
			+ '</li><li class=\"w10 no-right\"><em class=\"xq-icon\"></em></li></ul>'+hhtml
		
	return html;
	
	
}








